package com.company.ThreadsCommunication;

/**
 * 作者：13687
 * 日期：2017/6/5
 * 项目：ThreadPoolsDemo
 * 描述：增加线程
 */
public class IncreaseThread extends Thread {
	public IncreaseThread(NumberLockHolder numberHolder) {
		this.numberHolder = numberHolder;
	}

	//	private NumberHolder numberHolder;
	private NumberLockHolder numberHolder;

/*	public IncreaseThread(NumberHolder numberHolder) {
		this.numberHolder = numberHolder;
	}*/

	@Override
	public void run() {
		for (int i = 0; i < 20; ++i) {
			// 进行一定的延时
			try {
				Thread.sleep((long) Math.random() * 1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

			// 进行增加操作
			numberHolder.increase();
		}
	}

}
